package com.obradovicnjegovan.webprodavnica.so.impl;

import org.apache.tapestry5.ioc.annotations.Inject;

import com.obradovicnjegovan.webprodavnica.dao.HibernateDao;
import com.obradovicnjegovan.webprodavnica.so.SacuvajIliAzuriraj;

public class SacuvajIliAzurirajImpl<T> implements SacuvajIliAzuriraj<T> {
	@Inject
	private HibernateDao hibernateDao;
	private T object;
	
	public HibernateDao getHibernateDao() {
		return hibernateDao;
	}
	public void setHibernateDao(HibernateDao hibernateDao) {
		this.hibernateDao = hibernateDao;
	}
	public T getObject() {
		return object;
	}
	public void setObject(T object) {
		this.object = object;
	}
	public Object execute() {
		try {
			hibernateDao.save(getObject());
			return "Uspesno sacuvan objekat klase " + getObject().getClass().getSimpleName();
		} catch (Exception e) {
			return "Sistemska greska. Neuspesno sacuvana objekat. Problem: " + e;
		}
	}
}
